package com.lzm.ydpt.entity.mall;

import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.RequiresApi;

import java.util.Objects;

/**
 * 订单商品
 */
public class ShopGoods implements Parcelable {

    private long cart_id;
    private long order_goods_id;
    private long order_refund_id;
    private long goods_id;
    private long option_id;
    private String image_src;
    private String title;
    private String spec_title;
    private int gold;
    private int price_gold;
    private int total;
    private int refund_state; // 退款状态 1:申请退款，2:退款完成，3：退款关闭，4：退款失败
    private String price_rmb;
    private int gift_flag;
    // sku
    private int inventory;
    private int sales_volume;//销量
    private String market_price;//市场价
    private String spec_ids;
    private boolean isSelect;
    private int invail; // 0 正常 1失效
    private int type; // 失效原因 1：不在服务范围内，2：商品已下架，3：库存不在
    private int state;//商品状态, 0：默认，1：已上架，2：已下架 ，3：已售罄

    protected ShopGoods(Parcel in) {
        cart_id = in.readLong();
        order_goods_id = in.readLong();
        order_refund_id = in.readLong();
        goods_id = in.readLong();
        option_id = in.readLong();
        image_src = in.readString();
        title = in.readString();
        spec_title = in.readString();
        gold = in.readInt();
        price_gold = in.readInt();
        total = in.readInt();
        refund_state = in.readInt();
        price_rmb = in.readString();
        inventory = in.readInt();
        sales_volume = in.readInt();
        market_price = in.readString();
        spec_ids = in.readString();
        isSelect = in.readByte() != 0;
        invail = in.readInt();
        type = in.readInt();
        state = in.readInt();
        gift_flag = in.readInt();
    }

    public static final Creator<ShopGoods> CREATOR = new Creator<ShopGoods>() {
        @Override
        public ShopGoods createFromParcel(Parcel in) {
            return new ShopGoods(in);
        }

        @Override
        public ShopGoods[] newArray(int size) {
            return new ShopGoods[size];
        }
    };

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ShopGoods)) return false;
        ShopGoods shopGoods = (ShopGoods) o;
        return goods_id == shopGoods.goods_id &&
                option_id == shopGoods.option_id;
    }

    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
    @Override
    public int hashCode() {
        return Objects.hash(goods_id, option_id);
    }

    public long getCart_id() {
        return cart_id;
    }

    public void setCart_id(long cart_id) {
        this.cart_id = cart_id;
    }

    public long getOrder_goods_id() {
        return order_goods_id;
    }

    public void setOrder_goods_id(long order_goods_id) {
        this.order_goods_id = order_goods_id;
    }

    public long getOrder_refund_id() {
        return order_refund_id;
    }

    public void setOrder_refund_id(long order_refund_id) {
        this.order_refund_id = order_refund_id;
    }

    public long getGoods_id() {
        return goods_id;
    }

    public void setGoods_id(long goods_id) {
        this.goods_id = goods_id;
    }

    public long getOption_id() {
        return option_id;
    }

    public void setOption_id(long option_id) {
        this.option_id = option_id;
    }

    public String getImage_src() {
        return image_src;
    }

    public void setImage_src(String image_src) {
        this.image_src = image_src;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSpec_title() {
        return spec_title;
    }

    public void setSpec_title(String spec_title) {
        this.spec_title = spec_title;
    }

    public int getGold() {
        return gold;
    }

    public void setGold(int gold) {
        this.gold = gold;
    }

    public int getPrice_gold() {
        return price_gold;
    }

    public void setPrice_gold(int price_gold) {
        this.price_gold = price_gold;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getRefund_state() {
        return refund_state;
    }

    public void setRefund_state(int refund_state) {
        this.refund_state = refund_state;
    }

    public String getPrice_rmb() {
        return price_rmb;
    }

    public void setPrice_rmb(String price_rmb) {
        this.price_rmb = price_rmb;
    }

    public int getInventory() {
        return inventory;
    }

    public void setInventory(int inventory) {
        this.inventory = inventory;
    }

    public int getSales_volume() {
        return sales_volume;
    }

    public void setSales_volume(int sales_volume) {
        this.sales_volume = sales_volume;
    }

    public String getMarket_price() {
        return market_price;
    }

    public void setMarket_price(String market_price) {
        this.market_price = market_price;
    }

    public String getSpec_ids() {
        return spec_ids;
    }

    public void setSpec_ids(String spec_ids) {
        this.spec_ids = spec_ids;
    }

    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
    }

    public int getInvail() {
        return invail;
    }

    public void setInvail(int invail) {
        this.invail = invail;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getGift_flag() {
        return gift_flag;
    }

    public void setGift_flag(int gift_flag) {
        this.gift_flag = gift_flag;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(cart_id);
        dest.writeLong(order_goods_id);
        dest.writeLong(order_refund_id);
        dest.writeLong(goods_id);
        dest.writeLong(option_id);
        dest.writeString(image_src);
        dest.writeString(title);
        dest.writeString(spec_title);
        dest.writeInt(gold);
        dest.writeInt(price_gold);
        dest.writeInt(total);
        dest.writeInt(refund_state);
        dest.writeString(price_rmb);
        dest.writeInt(inventory);
        dest.writeInt(sales_volume);
        dest.writeString(market_price);
        dest.writeString(spec_ids);
        dest.writeByte((byte) (isSelect ? 1 : 0));
        dest.writeInt(invail);
        dest.writeInt(type);
        dest.writeInt(state);
        dest.writeInt(gift_flag);
    }
}